{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "0fb45014-51a3-47c4-ba1d-7ec614440d68",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "裁剪前序列为：\n",
      " [[1, 2, 3, 9], [4, 5, 6], [7, 8]]\n",
      "裁剪后序列为：\n",
      " [[3 9]\n",
      " [5 6]\n",
      " [7 8]]\n"
     ]
    }
   ],
   "source": [
    "import tensorflow as tf\n",
    "s=[[1,2,3,9],[4,5,6],[7,8]]\n",
    "print(\"裁剪前序列为：\\n\",s)\n",
    "a=tf.keras.preprocessing.sequence.pad_sequences(s,maxlen=2)\n",
    "print(\"裁剪后序列为：\\n\",a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6f216798-d3ef-4108-a1e9-4d9fefbddb05",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:base] *",
   "language": "python",
   "name": "conda-base-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
